home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Information / Digests / CSMP Digest / volume 3 / csmp-digest-v3-073 / doubleCR.1 < prev   
Encoding:
Text File  |  1995-12-31  |  33.6 KB  |  874 lines

  1. C.S.M.P. Digest             Sun, 04 Dec 94       Volume 3 : Issue 73
  2.  
  3. Today's Topics:
  4.  
  5.         ? THINK Pascal: calling code
  6.         Any science to segmenting?
  7.         Plug-Ins w- CFM
  8.         Saving a PICT to a file - how?
  9.         Sprite Animation Toolkit 2.3a1
  10.         UPP's & calling completion procs
  11.  
  12.  
  13.  
  14. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  15. (pottier@clipper.ens.fr).
  16.  
  17. The digest is a collection of article threads from the internet newsgroup
  18. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  19. regularly and want an archive of the discussions.  If you don't know what a
  20. newsgroup is, you probably don't have access to it.  Ask your systems
  21. administrator(s) for details.  If you don't have access to news, you may
  22. still be able to post messages to the group by using a mail server like
  23. anon.penet.fi (mail help@anon.penet.fi for more information).
  24.  
  25. Each issue of the digest contains one or more sets of articles (called
  26. threads), with each set corresponding to a 'discussion' of a particular
  27. subject.  The articles are not edited; all articles included in this digest
  28. are in their original posted form (as received by our news server at
  29. nef.ens.fr).  Article threads are not added to the digest until the last
  30. article added to the thread is at least two weeks old (this is to ensure that
  31. the thread is dead before adding it to the digest).  Article threads that
  32. consist of only one message are generally not included in the digest.
  33.  
  34. The digest is officially distributed by two means, by email and ftp.
  35.  
  36. If you want to receive the digest by mail, send email to listserv@ens.fr
  37. with no subject and one of the following commands as body:
  38.     help                        Sends you a summary of commands
  39.     subscribe csmp-digest Your Name    Adds you to the mailing list
  40.     signoff csmp-digest            Removes you from the list
  41. Once you have subscribed, you will automatically receive each new
  42. issue as it is created.
  43.  
  44. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
  45. Questions related to the ftp site should be directed to
  46. scott.silver@dartmouth.edu. Currently no previous volumes of the CSMP
  47. digest are available there.
  48.  
  49. Also, the digests are available to WAIS users.  To search back issues
  50. with WAIS, use comp.sys.mac.programmer.src. With Mosaic, use
  51. http://www.wais.com/wais-dbs/comp.sys.mac.programmer.html.
  52.  
  53.  
  54. -------------------------------------------------------
  55.  
  56. >From ase@cyberspace.org (Ashley A Thomas)
  57. Subject: ? THINK Pascal: calling code
  58. Date: Fri, 18 Nov 1994 16:51:15 +1100
  59. Organization: little to none
  60.  
  61. Could someone tell me where to find a good desription of how to write and
  62. use code you call from inside your program with THINK Pascal in the same
  63. way C programs can by calling a routine by passing a pointer to it.
  64.  
  65. e.g. running code in a resource given its handle (like dnr); or passing a
  66. pointer to a procedure to be called somewhere else.
  67.  
  68. Thanks!
  69. ASE
  70.  
  71. -- 
  72.  
  73. Ashley A Thomas
  74. Email: ase@cyberspace.org
  75.  
  76. +++++++++++++++++++++++++++
  77.  
  78. >From ingemar@lysator.liu.se (Ingemar Ragnemalm)
  79. Date: 20 Nov 1994 12:59:59 GMT
  80. Organization: (none)
  81.  
  82. ase@cyberspace.org (Ashley A Thomas) writes:
  83.  
  84. >Could someone tell me where to find a good desription of how to write and
  85. >use code you call from inside your program with THINK Pascal in the same
  86. >way C programs can by calling a routine by passing a pointer to it.
  87.  
  88. >e.g. running code in a resource given its handle (like dnr); or passing a
  89. >pointer to a procedure to be called somewhere else.
  90.  
  91. The following inline function is taken from TransSkel.p:
  92.  
  93.     procedure CallpInt (myInt: integer; myProc: ProcPtr);
  94.  
  95. { Two calls use integer as one parameter arguments.  This procedure handles    }
  96. { both of them.                                                                            }
  97.  
  98.     inline
  99.         $205f,     {movea.l  (a7)+,a0        ; (a0) is a ptr to string, 4(a0) is mode}
  100.         $4e90;
  101.  
  102.  
  103. By calling CallpInt, you call the procedure that myProc points to, with myInt
  104. as argument. Unfortunately, there is no type-checking done, so you are
  105. responsible for sending a pointer to a procedure that takes exactly the
  106. arguments you assume.
  107.  
  108. myProc can be created by taking the address of the procedure (e.g.
  109. myProc := @MyProcedure;), or by dereferencing a handle to a code resource
  110. (after locking it!), e.g. something like:
  111.  
  112. myCode := GetResource('CODE', 9999);
  113. if myCode = nil then
  114.     HandleError
  115. else begin
  116.     HLock(myCode);
  117.     myProc := myCode^;
  118. end;
  119.  
  120. You can change the above inline to any other argument list simply by adding
  121. or replacing arguments.
  122.  
  123. Calling procedure pointers should really be built-in into Pascal, just as it
  124. is in Modula2, so we didn't have to do this kind of workarounds. Most of all,
  125. I want type checking on my procedure pointers. Perhaps we could convince
  126. MetroWerks to add it?
  127.  
  128. --
  129. - -
  130. Ingemar Ragnemalm, PhD
  131. Image processing, Mac shareware games
  132. E-mail address: ingemar@isy.liu.se or ingemar@lysator.liu.se
  133.  
  134. ---------------------------
  135.  
  136. >From ikb_macd@ece.concordia.ca (Keith MacDonald)
  137. Subject: Any science to segmenting?
  138. Date: 8 Nov 1994 04:23:04 GMT
  139. Organization: ECE - Concordia University
  140.  
  141.  
  142. Should I be practising any science in determining which procedures are
  143. grouped into the same segments when I code or is there little/no
  144. overhead in jumping from one segment to another?
  145.  
  146. Cheers,
  147. Keith
  148. ___________________________________________________________________________
  149.  Keith MacDonald                                       Computer Engineering
  150.  ikb_macd@ECE.concordia.ca                             Concordia University
  151.  http://www.ece.concordia.ca/~ikb_macd/addr.html       Montreal, QC, Canada
  152.  
  153. +++++++++++++++++++++++++++
  154.  
  155. >From nick+@pitt.edu ( nick.c )
  156. Date: Tue, 08 Nov 1994 01:05:54 -0500
  157. Organization: The Pitt, Chemistry
  158.  
  159. In article <39muf8$9mu@newsflash.concordia.ca>, ikb_macd@ece.concordia.ca
  160. (Keith MacDonald) wrote:
  161.  
  162. > Should I be practising any science in determining which procedures are
  163. > grouped into the same segments when I code or is there little/no
  164. > overhead in jumping from one segment to another?
  165.  
  166.    My understanding is a segment is swapped into memory as a whole.
  167.      So, (and I'm reasoning here, not speaking with any authority)
  168.      it would make sense to me to group functions that call each
  169.      other together into the same segment.  Try and make each segment
  170.      as "self contained" as possible (realizing that no segment
  171.      could be entirely self contained - or it would be unnecessary
  172.      to 'main').  This would minimize the efficiency loss of swapping
  173.      in segments.  'Course with the modern memory structure of the
  174.      Mac, I'm not sure this "swapping" ocurrs any longer... dunno.
  175.  
  176.  
  177.  Internet: nick+@pitt.edu            _/   _/  _/  _/_/_/   _/   _/  
  178.    eWorld: nick                     _/_/ _/  _/  _/   _/  _/_/_/ 
  179.       CIS: 71232,766               _/ _/_/  _/  _/       _/ _/    
  180.      http://www.pitt.edu/~nick/   _/   _/  _/   _/_/_/  _/   _/     
  181.                     
  182.  
  183. +++++++++++++++++++++++++++
  184.  
  185. >From ramer@nrc.uab.edu (Kevin W. Ramer)
  186. Date: Wed, 09 Nov 1994 09:07:44 -0600
  187. Organization: University of Alabama at Birmingham
  188.  
  189. In article <nick+-0811940105540001@ehdup-f-1.slip.net.pitt.edu>,
  190. nick+@pitt.edu ( nick.c ) wrote:
  191. > > Should I be practising any science in determining which procedures are
  192. > > grouped into the same segments ?
  193.  
  194. >    My understanding is a segment is swapped into memory as a whole.
  195. >      So, (and I'm reasoning here, not speaking with any authority)
  196. >      it would make sense to me to group functions that call each
  197. >      other together into the same segment.  Try and make each segment
  198. >      as "self contained" as possible (realizing that no segment
  199. >      could be entirely self contained - or it would be unnecessary
  200. >      to 'main').  This would minimize the efficiency loss of swapping
  201. >      in segments.  'Course with the modern memory structure of the
  202. >      Mac, I'm not sure this "swapping" ocurrs any longer... dunno.
  203.  
  204. A couple of additional points to be made are 1) if you wish to have 
  205. segments  unloaded, do so from the main segment. Typically, calling 
  206. UnloadSeg each time through your event loop.  2) If you don't stick
  207. to 1 be sure to never unload segments earlier in the calling chain !
  208. For example, main calls A which calls B (each in different segments)
  209. _do not_ UnloadSeg(A) while in B.  Makes for nasty crashes.
  210.  
  211. -- 
  212. Kevin W. Ramer                   ramer@nrc.uab.edu
  213. Programmer Analyst
  214. Neurobiology Research Center
  215. University of Alabama at Birmingham
  216.  
  217. +++++++++++++++++++++++++++
  218.  
  219. >From pgontier@novell.com (Pete Gontier)
  220. Date: Wed, 09 Nov 1994 09:42:45 -0800
  221. Organization: Novell, Inc., Walnut Creek/Macintosh Site
  222.  
  223. In article <nick+-0811940105540001@ehdup-f-1.slip.net.pitt.edu>,
  224. nick+@pitt.edu ( nick.c ) wrote:
  225.  
  226. > 'Course with the modern memory structure of the
  227. > Mac, I'm not sure this "swapping" ocurrs any longer... dunno.
  228.  
  229. Yes, it does. The Modern Memory Manager just has better (read: faster)
  230. heap management. It doesn't try to tell anyone what to do with individual
  231. heap blocks, which of course are what contain each code segment. You may
  232. be thinking of the Power Mac code model, which has a new paging scheme for
  233. code fragments in the data fork, assuming VM is turned on.
  234.  
  235. I might as well add, now that I have followed up, that a successful
  236. segmentation strategy has to be planned ahead of time. The good news is
  237. that the strategy has a lot in common with good engineering practice
  238. regardless of segmentation, so if you are a good engineering citizen, you
  239. probably *accidentally* planned your segmentation strategy ahead of time
  240. :-). More specifically, if you have narrow entry points into your
  241. functional sub-systems, you can simply put each sub-system into its own
  242. segment and unload it when it's not needed.
  243.  
  244. -- 
  245.  The views expressed here do not necessarily reflect those of my employer.
  246.  
  247. +++++++++++++++++++++++++++
  248.  
  249. >From Rick_Holzgrafe@taligent.com (Rick Holzgrafe)
  250. Date: Tue, 8 Nov 1994 18:41:38 GMT
  251. Organization: Semicolon Software
  252.  
  253. In article <39muf8$9mu@newsflash.concordia.ca>, ikb_macd@ece.concordia.ca
  254. (Keith MacDonald) wrote:
  255.  
  256. > Should I be practising any science in determining which procedures are
  257. > grouped into the same segments when I code or is there little/no
  258. > overhead in jumping from one segment to another?
  259.  
  260. Segments exist mainly for memory management purposes: they allow you to
  261. group relevant portions of your code into chunks which do not have to be
  262. kept in memory when they are not in use. For example, your initialization
  263. code runs only once, when the app starts up: put it all into a segment,
  264. and unload it when initialization is complete. You may have printing code
  265. which can be cleanly separated from the rest of your code; there's no need
  266. for it to be in memory when the user isn't printing -- and so on. This
  267. makes more efficient use of your heap and allows your app to run in less
  268. memory.
  269.  
  270. There is a slight performance hit when making calls across segments,
  271. because they must pass through the jump table. Normally it's not worth
  272. worrying about, but I wouldn't call segment B from inside a tight, long,
  273. hopefully-fast loop in segment A. If you segment your code functionally,
  274. this will generally not happen anyway.
  275.  
  276. You should be aware that segments are loaded automagically the first time
  277. any function in them is called, but they are never unloaded unless you do
  278. so specifically in your code. This has a couple of effects. One effect is
  279. that *any* routine can move memory if it is in an unloaded segment when
  280. you call it, because its segment will be loaded into your heap before the
  281. routine can be called. Another effect is that you need to be intelligent
  282. about unloading your segments if you want to reap the memory-management
  283. benefits. A common practice is to keep your main event loop in segment 0
  284. (that is, the one that contains your main routine), and each time through
  285. the event loop, unload every other segment you've got. Unloading a segment
  286. doesn't force it from memory, it just frees it to move in the heap and to
  287. be purged if needed when memory gets low. Commonly used segments will
  288. therefore incur no serious performance penalty from being repeatedly
  289. unloaded unless memory is low; the user can then improve performance by
  290. allocating more memory to the app, if more memory is available.
  291.  
  292. Exceptions to the automagical loading of segments: returns from
  293. subroutines do *not* force loading of segments, and segments cannot be
  294. loaded at interrupt level. Never unload a segment if your call stack
  295. contains pointers into it, or if you are using interrupt-level callbacks
  296. (e.g. from VBL or slot queues, async sound calls, async network calls, and
  297. the like) to routines in the segment. (I got into trouble once by calling
  298. my main event handler from a routine in a different segment; the main
  299. event handler was innocently unloading the segment that called it.
  300. Intermittently [whenever something stirred up the heap just wrong] it
  301. would crash when trying to return to the unloaded segment.)
  302.  
  303. Segments can be marked "preload" in the resource fork if you want them
  304. loaded at startup; if you never explicitly unload them, then they'll
  305. always be there when you need them.
  306.  
  307. Hope this helps.
  308.  
  309. -- Rick Holzgrafe, a member of the Taligentsia
  310.    Rick_Holzgrafe@taligent.com
  311.    rmh@taligent.com
  312.  
  313. +++++++++++++++++++++++++++
  314.  
  315. >From curreyr@halcyon.halcyon.com (curreyr)
  316. Date: 19 Nov 1994 10:16:54 GMT
  317. Organization: Northwest Nexus Inc.
  318.  
  319. In article <Rick_Holzgrafe-0811941041380001@ricks-cafe.taligent.com>
  320. Rick_Holzgrafe@taligent.com (Rick Holzgrafe) writes:
  321.  
  322. > You should be aware that segments are loaded automagically the first time
  323. > any function in them is called, but they are never unloaded unless you do
  324. > so specifically in your code. This has a couple of effects. One effect is
  325. > that *any* routine can move memory if it is in an unloaded segment when
  326. > you call it, because its segment will be loaded into your heap before the
  327.  
  328. Another "effect" is that it can FAIL to load if there isn't room in the
  329. heap for the segment. This can be bad news to your users. If you ignore
  330. this fact, and the segment fails to load, your code had better handle
  331. this fact. But handling the failure is a pain in the @#$@. How many
  332. apps can you name that handle low memory situations reliably?
  333.  
  334. My suggestion would be to use a modern application framework that hides
  335. the ugly details of segmentation loading/unloading and follow the
  336. advice others have given on segmenting your code. MacApp maintains a
  337. reserve in order to insure that there is always going to be memory
  338. available for that code segments to be loaded and could be used as an
  339. example if you want to "roll your own".
  340.  
  341. -Robert Currey
  342.  
  343. ---------------------------
  344.  
  345. >From mdaw@alias.com (Matt Daw)
  346. Subject: Plug-Ins w- CFM
  347. Date: Wed, 16 Nov 1994 03:50:10 GMT
  348. Organization: Alias Research Inc.
  349.  
  350. Has anybody implemented a way to do plug-ins (ala PhotoShop) with the Code
  351. Fragment Manager? If so, what is the best way of doing this?
  352.  
  353. - ---------------------
  354. | Matt Daw            |
  355. | Alias Research Inc. |
  356. - ---------------------
  357.  
  358. +++++++++++++++++++++++++++
  359.  
  360. >From h+@metrowerks.com (Jon W{tte)
  361. Date: Sat, 19 Nov 1994 15:40:34 +0100
  362. Organization: The Conspiracy
  363.  
  364. In article <mdaw-1511942250100001@192.75.21.44>,
  365. mdaw@alias.com (Matt Daw) wrote:
  366.  
  367. >Has anybody implemented a way to do plug-ins (ala PhotoShop) with the Code
  368. >Fragment Manager? If so, what is the best way of doing this?
  369.  
  370. It's REALLY easy. You just load the fragment from disk, and get 
  371. the value of the symbol you want (like "main") and call it as a 
  372. function pointer. NO PAIN!
  373.  
  374. Unless you're on the 68K, in which case it's #$GUffaw
  375.  
  376. <What was that?>
  377. <The manager for the CFM 68K, tiring of the flames and 
  378. putting them out>
  379. <Oh!>
  380.  
  381. Cheers,
  382.  
  383.                     / h+
  384.  
  385.  
  386. --
  387.   Jon W‰tte (h+@metrowerks.com), Hagagatan 1, 113 48 Stockholm, Sweden
  388.   "Psychotherapist" - "Psycho-The-Rapist"
  389.    Pure coincidence? You decide!
  390.  
  391.  
  392. ---------------------------
  393.  
  394. >From andy@dijkstra.cs.clemson.edu (Andrew Greenshields)
  395. Subject: Saving a PICT to a file - how?
  396. Date: 16 Nov 1994 00:43:29 GMT
  397. Organization: Clemson University
  398.  
  399.  
  400.   I have finally got my text file to convert to a nice infra-red image
  401. which I now have in the format of a PICT.  However, when I try to save
  402. this PICT as a file I am running into trouble.  I am using
  403. GetHandleSize to find out how big the PICT is and then I am using
  404. SFWrite to write the data to a file.  I am using *thePict as the
  405. pointer to the data, where thePict is of type PicHandle.  When I try
  406. and look at this file using Photoshop it tells me there is a problem
  407. reading this file.  What am I doing wrong?
  408.  
  409.   Any help would be greatly appreciated.
  410.  
  411.  
  412. Thanks in advance,
  413.  
  414. Andy
  415.  
  416. -- 
  417.   Andrew J. Greenshields N3IGS    |  Some people can tell what time it is by
  418.   andy@cs.clemson.edu             |  looking at the Sun, but I have never been
  419.   USPA C-24393                    |  able to make out the numbers.
  420. - ---------------------***STANDARD DISCLAIMERS APPLY***------------------------
  421.  
  422. +++++++++++++++++++++++++++
  423.  
  424. >From blm@coho.halcyon.com (Brian L. Matthews)
  425. Date: 16 Nov 1994 18:14:08 GMT
  426. Organization: NWNEXUS, Inc. - Making Internet Easy
  427.  
  428. In article <3abkjh$5jm@hubcap.clemson.edu>,
  429. Andrew Greenshields <andy@dijkstra.cs.clemson.edu> wrote:
  430. | I am using GetHandleSize to find out how big the PICT is and then I
  431. |am using SFWrite to write the data to a file.
  432.  
  433. A PICT file starts with a 512-byte header before the actual PICT data.
  434. This header is for use by applications, and as far as I know, there aren't
  435. any standards for what goes in there, except one.  If it's all zeroes,
  436. you're fine.  So, before calling FSWrite to put the picture data in the
  437. file, do a:
  438.  
  439.     err = SetFPos (fRefNum, 1, 512);
  440.  
  441. If you've just created the file, this will effectively put 512 0s at
  442. the start of the file.  Note that if you're writing to an existing file,
  443. you may actually have to do an FSWrite of 512 0s to ensure they're there.
  444.  
  445. Brian
  446. --
  447. Brian L. Matthews                    blm@halcyon.com
  448.   "Look past the ghost that hides Hell's treasures." -Sky Cries Mary
  449.  
  450. +++++++++++++++++++++++++++
  451.  
  452. >From ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  453. Date: 17 Nov 94 16:59:07 +1300
  454. Organization: University of Waikato, Hamilton, New Zealand
  455.  
  456. In article <3adi5g$qed@news.halcyon.com>, blm@coho.halcyon.com (Brian L. Matthews) writes:
  457. >
  458. > A PICT file starts with a 512-byte header before the actual PICT data.
  459. > This header is for use by applications, and as far as I know, there aren't
  460. > any standards for what goes in there, except one.  If it's all zeroes,
  461. > you're fine.  So, before calling FSWrite to put the picture data in the
  462. > file, do a:
  463. >
  464. >     err = SetFPos (fRefNum, 1, 512);
  465. >
  466. > If you've just created the file, this will effectively put 512 0s at
  467. > the start of the file.
  468.  
  469. No, it will not. You must explicitly write 512 bytes of zeroes in all cases.
  470.  
  471. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  472. Computer Services Dept                     fax: +64-7-838-4066
  473. University of Waikato            electric mail: ldo@waikato.ac.nz
  474. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+13:00
  475.  
  476. +++++++++++++++++++++++++++
  477.  
  478. >From blm@chinook.halcyon.com (Brian L. Matthews)
  479. Date: 17 Nov 1994 18:26:54 GMT
  480. Organization: NWNEXUS, Inc. - Making Internet Easy
  481.  
  482. In article <1994Nov17.165907.35371@waikato.ac.nz>,
  483. Lawrence D'Oliveiro, Waikato University <ldo@waikato.ac.nz> wrote:
  484. |>     err = SetFPos (fRefNum, 1, 512);
  485. |> If you've just created the file, this will effectively put 512 0s at
  486. |> the start of the file.
  487. |No, it will not. You must explicitly write 512 bytes of zeroes in all cases.
  488.  
  489. Argh.  Lawrence is, of course, absolutely right.  I always seem to get
  490. Unix and the Mac confused in cases like this.  Anyway, I was actually
  491. wrong twice.  First, SetFPos will fail if you attempt to set the file
  492. position beyond the end of file.  And second, if you use SetEOF before
  493. the SetFPos, it doesn't fill with 0s.  So while I was right about needing
  494. the 512 0s, I screwed up how to get them there. :-)
  495.  
  496. Brian
  497. --
  498. Brian L. Matthews                    blm@halcyon.com
  499.   "Look past the ghost that hides Hell's treasures." -Sky Cries Mary
  500.  
  501. +++++++++++++++++++++++++++
  502.  
  503. >From andy@dijkstra.cs.clemson.edu (Andrew Greenshields)
  504. Date: 18 Nov 1994 01:32:04 GMT
  505. Organization: Clemson University
  506.  
  507. In article <3ag79e$2vj@news.halcyon.com> blm@chinook.halcyon.com (Brian L. Matthews) writes:
  508. >In article <1994Nov17.165907.35371@waikato.ac.nz>,
  509. >Lawrence D'Oliveiro, Waikato University <ldo@waikato.ac.nz> wrote:
  510.  
  511.   Thankyou both, I can now successfully save my PICTs to files!
  512.  
  513. Andy
  514.  
  515.  
  516. -- 
  517.   Andrew J. Greenshields N3IGS    |  Some people can tell what time it is by
  518.   andy@cs.clemson.edu             |  looking at the Sun, but I have never been
  519.   USPA C-24393                    |  able to make out the numbers.
  520. - ---------------------***STANDARD DISCLAIMERS APPLY***------------------------
  521.  
  522. +++++++++++++++++++++++++++
  523.  
  524. >From rollin@newton.apple.com (Keith Rollin)
  525. Date: Sun, 20 Nov 1994 22:56:08 -0800
  526. Organization: Apple ][ -> Mac -> Taligent -> Newton -> Windows?
  527.  
  528. In article <3abkjh$5jm@hubcap.clemson.edu>, andy@dijkstra.cs.clemson.edu
  529. (Andrew Greenshields) wrote:
  530.  
  531. >  I have finally got my text file to convert to a nice infra-red image
  532. >which I now have in the format of a PICT.  However, when I try to save
  533. >this PICT as a file I am running into trouble.  I am using
  534. >GetHandleSize to find out how big the PICT is and then I am using
  535. >SFWrite to write the data to a file.  I am using *thePict as the
  536. >pointer to the data, where thePict is of type PicHandle.  When I try
  537. >and look at this file using Photoshop it tells me there is a problem
  538. >reading this file.  What am I doing wrong?
  539.  
  540. PICT files begin with a 512 byte header (documented in an old Technote and
  541. in NIM:Imaging with QuickDraw). You don't mention that you are providing
  542. for this header, so that might be your problem.
  543.  
  544. The 512 byte header is for application-defined purposes. If you don't need
  545. to use it, you should clear it out (set it to zero) so as not to confuse
  546. another application that may try interpreting it.
  547.  
  548. - --------------------------------------------------------------------------
  549. Keith Rollin --- Phantom Programmer --- Apple Computer, Inc. --- Team Newton
  550. "I say, let's write "wacko" on all the rocks and be done with it."
  551.  
  552. ---------------------------
  553.  
  554. >From ingemar@lysator.liu.se (Ingemar Ragnemalm)
  555. Subject: Sprite Animation Toolkit 2.3a1
  556. Date: 19 Nov 1994 18:12:06 GMT
  557. Organization: (none)
  558.  
  559. Sprite Animation Toolkit 2.3, alpha version 1, is now available by
  560. ftp from ftp.uu.net, in the /tmp directory, as sat23a1.hqx. It will
  561. probably not remain there for more than a week.
  562.  
  563. Sprite Animation Toolkit is a programming library for making sprite-based
  564. animations (e.g. games). It includes a large number of demos, ranging from
  565. trivially simple to a complete game. It has been used for producing over
  566. a dozen released games.
  567.  
  568. This version works with CodeWarrior (Pascal or C, not PPC yet) as well
  569. as the Think compilers. (Not MPW. Sorry.) Several new features have been
  570. added, and a few changes have been made to make it faster, use less
  571. memory and be more foolproof.
  572.  
  573. This is an alpha version. It is not thoroughly tested. All demos work just
  574. fine on all systems I have been able to try them on, but I need help to find
  575. out if there are any serious bugs left.
  576.  
  577. --
  578. - -
  579. Ingemar Ragnemalm, PhD
  580. Image processing, Mac shareware games
  581. E-mail address: ingemar@isy.liu.se or ingemar@lysator.liu.se
  582.  
  583. ---------------------------
  584.  
  585. >From D_Gladstone@cs.auckland.ac.nz (David Gladstone)
  586. Subject: UPP's & calling completion procs
  587. Date: Thu, 17 Nov 1994 08:55:53 +1200
  588. Organization: University of Auckland, New Zealand.
  589.  
  590.  
  591. Hi.  I have been having some conceptual problems with UPPs.  I am writing
  592. a Catalog Service Access Module driver which needs to call a completion
  593. routine.
  594.  
  595. I have been getting confused about how things work (especially with CFM68K
  596. on the horizon).  I wrote the following initially as a series of questions
  597. and (as is often the case) managed to find plausible answers just by trying
  598. to phrase the questions - so I have stated what I understand instead.  How
  599. accurate is my version of the story below.  It has been a while since I read
  600. develop 17 (16?) "Making the Leap to PowerPC"...
  601.  
  602.  
  603. The way I figure it, there are several situations that could occur at runtime
  604. for my driver:
  605.  
  606. 1. I am 68K code and the completion routine field is a ProcPtr
  607. 2. I am 68K code and the completion routine field is a UPP (either PPC or 68K
  608.    code fragment)
  609. 3. I am PPC code and the completion routine field is a UPP (either PPC or 68K
  610.    code fragment)
  611. 4. I am PPC code and the completion routine field is a ProcPtr (from a 68K,
  612.    non CFM68K app)
  613.    
  614.  
  615. Case 1 would occur when we are running on a PPC in emulation or on a 68K
  616. machine and an old piece of software calls me.  Since my code is 68K and
  617. I don't have CFM68K at my disposal the only option I have is to call
  618. the routine as if it were a ProcPtr (which is fine in this case).
  619.  
  620.  
  621. Case 2 would occur when a 68K version of the driver is running in emulation
  622. on a PPC or it is running on a 68K machine with CFM68K installed.
  623.  
  624. It would not be so difficult if CFM68K existed - I could use it to dispatch
  625. all UPP calls and it would determine whether the pointer was a real UPP or
  626. not.  However, without using CFM68K for the 68K version of the driver I 
  627. have to call any value in the completion routine field of the parameter
  628. block as if it were a ProcPtr.  This means that I will be jumping to the
  629. routine descriptor rather than the routine itself.  I presume that
  630. NewRoutineDescriptor() must put 68K code at the beginning of all routine
  631. descriptors to handle this.
  632.  
  633.  
  634.  
  635. Case 3 would occur when a PPC version of the driver is called by a CFM
  636. aware 68K or PPC app.
  637.  
  638. In this case just call CallUniversalProc to dispatch the call.
  639.  
  640.  
  641.  
  642. Case 4 would occur when a PPC version of the driver is called by an old 
  643. non-CFM68K application.
  644.  
  645. This must be handled by the Code Fragment Manager.  If you call
  646. CallUniversalProc with a ProcPtr it figures out that the address in 
  647. memory is not a routine descriptor and therefore should execute it as
  648. 68K code.
  649.  
  650.  
  651.  
  652.  
  653.  
  654. Is it really that simple?
  655.  
  656.  
  657. David Gladstone.
  658.  
  659. _________________________________________________________________________
  660. David Gladstone : Computer Science Department, University of Auckland, NZ
  661. david@cs.auckland.ac.nz : Ph. +64 9 373-7599 x 5336 : Fax: +64 9 373-7453
  662. _________________________________________________________________________
  663.                       "Give blood... Play Hockey." 
  664.  
  665.  
  666. +++++++++++++++++++++++++++
  667.  
  668. >From Jaeger@fquest.com (Brian Stern)
  669. Date: 17 Nov 1994 05:03:19 GMT
  670. Organization: The University of Texas at Austin, Austin, Texas
  671.  
  672. In article <D_Gladstone-1711940855530001@david.cs.aukuni.ac.nz>,
  673. D_Gladstone@cs.auckland.ac.nz wrote:
  674.  
  675. < Hi.  I have been having some conceptual problems with UPPs.  I am writing
  676. < a Catalog Service Access Module driver which needs to call a completion
  677. < routine.
  678.  
  679.   I presume that
  680. < NewRoutineDescriptor() must put 68K code at the beginning of all routine
  681. < descriptors to handle this.
  682.  
  683. Not Exactly.  If you're on a PowerMac, drop into macsBug and type 'il
  684. CopyBits'.  CopyBits is native.  What you'll see looks something like
  685. this:
  686.  
  687.             000C12AC   TB         E                 | AAFE
  688.             000C12AE   BTST       D3,D0             | 0700
  689.             000C12B0   ORI.B      #$00,D0           | 0000 0000
  690.             000C12B4   ORI.B      #$00,D0           | 0000 0000
  691.             000C12B8   ORI.B      #$BFC0,D3         | 0003 BFC0
  692.             000C12BC   ORI.B      #$04,D1           | 0001 0004
  693.             000C12C0   ORI.B      #$2C10,A3         | 000B 2C10
  694.             000C12C4   ORI.B      #$00,D0           | 0000 0000
  695.             000C12C8   ORI.B      #$00,D0           | 0000 0000
  696.             000C12CC   ORI.B      #$A8EF,D0         | 0000 A8EF
  697.  
  698. What you're looking at is the routine descriptor for Copybits.  Notice
  699. that the first word is AAFE.  That's the mixedmodemagic trap.  So when you
  700. call copybits you're actually jumping to the mixedmodemagic trap.  It
  701. knows the location of the rest of the routine descriptor and gets the
  702. information that it needs to jump to the appropriate code in the
  703. appropriate mode.
  704.  
  705. < Is it really that simple?
  706.  
  707. Pretty much.
  708. If you're 68K then all you know about are procptrs.  If you're PPC then
  709. you MUST use CallUniversalProc.  CallUniversalProc works correctly if the
  710. code it's pointing to is a routine descriptor or is 68K code.
  711.  
  712. < David Gladstone.
  713. < _________________________________________________________________________
  714. < David Gladstone : Computer Science Department, University of Auckland, NZ
  715. < david@cs.auckland.ac.nz : Ph. +64 9 373-7599 x 5336 : Fax: +64 9 373-7453
  716. < _________________________________________________________________________
  717. <                       "Give blood... Play Hockey."
  718.  
  719. -- 
  720. Brian  Stern  :-{)}
  721. Toolbox commando and Menu bard
  722. Jaeger@fquest.com
  723.  
  724. +++++++++++++++++++++++++++
  725.  
  726. >From wdh@fresh.com (Bill Hofmann)
  727. Date: Thu, 17 Nov 1994 17:54:50 GMT
  728. Organization: Fresh Software
  729.  
  730. In article <D_Gladstone-1711940855530001@david.cs.aukuni.ac.nz>,
  731. D_Gladstone@cs.auckland.ac.nz wrote:
  732. >....
  733. > The way I figure it, there are several situations that could occur at runtime
  734. > for my driver:
  735. > 1. I am 68K code and the completion routine field is a ProcPtr
  736. > 2. I am 68K code and the completion routine field is a UPP (either PPC or 68K
  737. >    code fragment)
  738. > 3. I am PPC code and the completion routine field is a UPP (either PPC or 68K
  739. >    code fragment)
  740. > 4. I am PPC code and the completion routine field is a ProcPtr (from a 68K,
  741. >    non CFM68K app)
  742. >....
  743. > Is it really that simple?
  744. Yes, it is.  Look at almost any header.  The proper way to call the
  745. completion proc is to define a set of macros (I bet they're already
  746. defined for CSAMs):
  747. #if ROUTINEDESCRIPTORS
  748. #define CallCSAMCompletionProc(proc, foo, bar)    \
  749.         CallUniversalProc(proc, uppCSAMCompletionProcInfo, (foo), (bar))
  750. #else
  751. #define CallCSAMCompletionProc(proc, foo, bar)     \
  752.         ((proc)((foo), (bar))
  753. #endif
  754. like so, look for more detail in any header.  Just use CallCSAMCompletionProc()
  755. in your code.
  756.  
  757. -Bill
  758.  
  759. -- 
  760. Bill Hofmann                                  wdh@fresh.com
  761. Fresh Software and Instructional Design       voice: +1 510 524 0852
  762. 1640 San Pablo Ave #C, Berkeley CA 94702 USA  fax:   +1 510 524 0853
  763.  
  764. +++++++++++++++++++++++++++
  765.  
  766. >From h+@metrowerks.com (Jon W{tte)
  767. Date: Fri, 18 Nov 1994 09:26:57 +0100
  768. Organization: The Conspiracy
  769.  
  770. In article <D_Gladstone-1711940855530001@david.cs.aukuni.ac.nz>,
  771. D_Gladstone@cs.auckland.ac.nz (David Gladstone) wrote:
  772.  
  773. >1. I am 68K code and the completion routine field is a ProcPtr
  774. >2. I am 68K code and the completion routine field is a UPP (either PPC or 68K
  775. >   code fragment)
  776.  
  777. Here, just blithely jump to the address. Things will work, 
  778. because the 68K code in the UPP includes the _MixedModeMagic 
  779. trap.
  780.  
  781. >3. I am PPC code and the completion routine field is a UPP (either PPC or 68K
  782. >   code fragment)
  783. >4. I am PPC code and the completion routine field is a ProcPtr (from a 68K,
  784. >   non CFM68K app)
  785.  
  786. If the API says this is now a UPP field, then you have to call 
  787. through with CallXXX() which will make sure that everything 
  788. works.
  789.  
  790. However, the way that the 68K CFM works (totally new glue 
  791. libraries; can't use old headers) and PPC emulation works, the 
  792. 68K CFM model will look just like the PPC model, i e do what 
  793. you'd do on the PPC and you will be fine.
  794.  
  795. That there is no architecture for CFM driver (and even less for 
  796. PPC drivers) probably has something to do with it as well. 
  797. Safest bet would be to write it in plain, non-CFM 68K code 
  798. until the new driver architecture rolls around.
  799.  
  800. Cheers,
  801.  
  802.                     / h+
  803.  
  804.  
  805. --
  806.   Jon W‰tte (h+@metrowerks.com), Hagagatan 1, 113 48 Stockholm, Sweden
  807.  
  808. "When I started hacking, we didnπt have ones. We had to make do with zeros."
  809.     ã Overheard by Andrew Craze
  810.  
  811.  
  812. +++++++++++++++++++++++++++
  813.  
  814. >From Bruce@hoult.actrix.gen.nz (Bruce Hoult)
  815. Date: Sat, 19 Nov 1994 01:43:04 +1300 (NZDT)
  816. Organization: (none)
  817.  
  818. Jaeger@fquest.com (Brian Stern) writes:
  819. >   I presume that
  820. > < NewRoutineDescriptor() must put 68K code at the beginning of all routine
  821. > < descriptors to handle this.
  822. > Not Exactly.  If you're on a PowerMac, drop into macsBug and type 'il
  823. > CopyBits'.  CopyBits is native.  What you'll see looks something like
  824. > this:
  825. >             000C12AC   TB         E                 | AAFE
  826. >             000C12AE   BTST       D3,D0             | 0700
  827. >             000C12B0   ORI.B      #$00,D0           | 0000 0000
  828. >             000C12B4   ORI.B      #$00,D0           | 0000 0000
  829. >             000C12B8   ORI.B      #$BFC0,D3         | 0003 BFC0
  830. >             000C12BC   ORI.B      #$04,D1           | 0001 0004
  831. >             000C12C0   ORI.B      #$2C10,A3         | 000B 2C10
  832. >             000C12C4   ORI.B      #$00,D0           | 0000 0000
  833. >             000C12C8   ORI.B      #$00,D0           | 0000 0000
  834. >             000C12CC   ORI.B      #$A8EF,D0         | 0000 A8EF
  835. > What you're looking at is the routine descriptor for Copybits.  Notice
  836. > that the first word is AAFE.  That's the mixedmodemagic trap.  So when you
  837. > call copybits you're actually jumping to the mixedmodemagic trap.  It
  838. > knows the location of the rest of the routine descriptor and gets the
  839. > information that it needs to jump to the appropriate code in the
  840. > appropriate mode.
  841.  
  842. You're running an old version of Macsbug.  My 6100 says:
  843.  
  844.             000B6FAC   _MixedModeMagic                       ; AAFE       | AAFE
  845.             000B6FAE   BTST       D3,D0                                   | 0700
  846.             000B6FB0   ORI.B      #$00,D0                                 | 0000 0000
  847.             000B6FB4   ORI.B      #$00,D0                                 | 0000 0000
  848.             000B6FB8   ORI.B      #$BFC0,D3                               | 0003 BFC0
  849.             000B6FBC   ORI.B      #$04,D1                                 | 0001 0004
  850.             000B6FC0   ORI.B      #$8A60,A2                  ; '`'        | 000A 8A60
  851.             000B6FC4   ORI.B      #$00,D0                                 | 0000 0000
  852.             000B6FC8   ORI.B      #$00,D0                                 | 0000 0000
  853.             000B6FCC   ORI.B      #$A8EF,D0                               | 0000 A8EF
  854.  
  855. -- Bruce
  856.  
  857.  
  858.  
  859.  
  860. ---------------------------
  861.  
  862. End of C.S.M.P. Digest
  863. **********************
  864.  
  865.  
  866. ˇ